package com.job.ming;

import java.util.Scanner;

/**
 * @author yangmingyu
 * @version 1.0
 * @since 2022-07-02 17:07:45
 */
public class Zhaoren {
        public static void main(String[] args) {
            Scanner sc=new Scanner(System.in);
            System.out.println("人数");
            int n=sc.nextInt();
            int daan=Zhaoren.getdaan(n);
            System.out.println("最终"+daan);
        }
        public static int getdaan(int n){
            int [] persons=new int[n];
            for (int i=0;i<persons.length;i++){
                persons[i]=i+1;
            }
            while (persons.length>3){
                int [] newpersons=new  int [persons.length-1];
                for(int i=3;i<persons.length;i++){
                    newpersons[i-3]=persons[i];
                }
                newpersons[newpersons.length-2]=persons[0];
                newpersons[newpersons.length-1]=persons[1];
                persons=newpersons;
            }
            return persons[1];
        }
    }